package www.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import www.admin.dao.ILendingPlatformDao;
import www.admin.model.LendingPlatform;
import www.admin.mybatis.Criteria;
import www.admin.service.ILendingPlatformService;
import www.admin.utils.Layui;
import www.admin.utils.MessageConstant;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 
 * LendingPlatform
 * 
 **/

@Service
public class LendingPlatformServiceImpl implements ILendingPlatformService{


	public Layui queryPage (Criteria<LendingPlatform> param){
		PageHelper.startPage(param.getStartIndex(), param.getPageSize());
		List<LendingPlatform> list = lendingPlatformRepository.queryPage(param);
			PageInfo<LendingPlatform> paInfo = new PageInfo<LendingPlatform>(list);
	return Layui.data((int)paInfo.getTotal(), paInfo.getList()); }

	public Integer queryPageCount (Criteria<LendingPlatform> param){
		return (Integer) lendingPlatformRepository.queryPageCount(param);
	}

	public LendingPlatform  queryEntity (String id ){
		return lendingPlatformRepository.queryEntity(id);
	}

	public String deleteById (String id ){
		int result = lendingPlatformRepository.deleteById(id);
			if ( result != 1) {
					return MessageConstant.USER_TYPE_8;
			}
			return null;
	}

	public String insert(LendingPlatform record ){
		int result = lendingPlatformRepository.insert(record);
		if ( result != 1) { 
			return MessageConstant.USER_TYPE_11;
		}
		return null;
	}

	public String update (Criteria<LendingPlatform> param){
		int result = lendingPlatformRepository.update(param);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_15;
			}
			return null;
	}
	
	@Override
	public List<LendingPlatform> queryPageList(Criteria<LendingPlatform> param) {
		return lendingPlatformRepository.queryPage(param);
	}

	@Resource
	private ILendingPlatformDao lendingPlatformRepository;

}